package com.colin.util.redisson;

import com.colin.util.properties.RedisProperties;
import javax.annotation.Resource;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.ClusterServersConfig;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RedissonConfig {
    
    @Resource
    private RedisProperties redisProperties;

    @Bean
    public RedissonClient redissonClient() {
        String[] ss = redisProperties.redissonHost.split(",");
        Config config = new Config();
        ClusterServersConfig clusterServersConfig = config.useClusterServers();
        clusterServersConfig.setScanInterval(redisProperties.scanInterval);
        clusterServersConfig.addNodeAddress(ss);
        clusterServersConfig.setPassword(redisProperties.password);

        return Redisson.create(config);
    }
    
}
